home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12482 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: inforamp.net!ts13-11
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP 2d dynamically allocated array
  5. Date: Wed, 20 Mar 96 05:32:20 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4io59p$n9v@sam.inforamp.net>
  8. References: <4ihkae$8nt@taco.cc.ncsu.edu>
  9. NNTP-Posting-Host: ts34-09.tor.inforamp.net
  10. Keywords: help, arrays
  11. X-Newsreader: News Xpress Version 1.0 Beta #4
  12.  
  13. In article <4ihkae$8nt@taco.cc.ncsu.edu>,
  14.    rbsteven@eos.ncsu.edu (Robert Barclay Stevenson) wrote:
  15. >
  16. >    I am trying to figure out a way to effectively dynamically allocate a 2d
  17. >array using new and delete operators.  I have tried using multiple 
  18. indirection
  19. >on something like:
  20. >int **array_;  //is this the same as array_[] ?
  21. >And then use something like:
  22. >array[depth] = new int[width];
  23. >But I think I has missed the boat somewhere along the way.  If someone could 
  24. >please point me in the right direction or send me a sample, I would be very
  25. >grateful.  Thanks a lot.
  26.  
  27. int **ai;
  28. ai = new int*[width];
  29. for (int i;i<depth;i++) ai[i] = new int;
  30.  
  31. Just a suggestion.  I have not compiled or debugged this.
  32.  
  33.  
  34. Agrivar
  35.  
  36. aka     Randy Charles Morin
  37.     MiddleWorld SoftWare
  38.     1-800-363-3780
  39.